#!/bin/sh -
#
# build script for 1.5
#
# If it's given a buildname it creates a subdirectory and places a build in it,
# otherwise it just creates the docs and class files.
#

if [ "${JDKPATH}" = "" ] 
then
	JDKPATH=/usr/lib/jvm/java-8-openjdk-amd64
fi
if [ "${JDK5PATH}" = "" ] 
then
	JDK5PATH=/usr/lib/jvm/java-1.5.0-oracle-i586/
fi

JAVA_HOME=$JDKPATH
export JAVA_HOME

PATH=$JDKPATH/bin:$PATH
export PATH

if [ "$1" = "test" ]
then
    #
    # Note: always do a full build before running test
    #
    JAVA_HOME=$JDK5PATH
    export JAVA_HOME

    PATH=$JDK5PATH/bin:$PATH
    export PATH

    ant -f ant/jdk15+.xml test
elif [ "$1" = "clean" ]
then
    ant -f ant/jdk15+.xml clean
else
    if ant -f ant/jdk15+.xml build-provider
    then
        ant -f ant/jdk15+.xml build
        ant -f ant/jdk15+.xml zip-src
    fi
    if [ -f build/artifacts/jdk1.5/jars/bcprov-jdk15to18*.jar ]
    then
    	tar cf - prov/src/main/resources/META-INF | (cd build/artifacts/jdk1.5/jars/; tar xf -)
        cd build/artifacts/jdk1.5/jars/
        mv prov/src/main/resources/META-INF .
        jar uf bcprov-jdk15to18*.jar META-INF
        jar uf bcprov-ext-jdk15to18*.jar META-INF
        rm -r prov META-INF
    fi
fi

